/*
 * ebc_errno.c - EBC - error handling
 * Clunix, Donghyun Kim, ryan@clunix.com, 2001.11.7
 *
 * Copyright (c) 2001 by Clunix Inc. All Rights Reserved.
 */
#include "config.h"

#include "libebc.h"

static char *ebc_strerr[] = {
	"success",		/* EBC_OK			0 */
	"general error",	/* ERR_EBC_GENERAL		-1 */
	"timeout",		/* EBC_ERR_TIMEOUT		-2 */
	"disconnected",		/* ERR_EBC_DISCONN		-3 */
	"invalid argument",	/* ERR_EBC_INVARG		-4 */
	"would block",		/* ERR_EBC_AGAIN		-5 */
	"wrong message",	/* ERR_EBC_WRONGMSG		-6 */
	"not supported",	/* ERR_EBC_NOTSUPPORTED		-7 */
	"invalid target",	/* ERR_EBC_INVTARGET		-8 */
	"no route found",	/* ERR_EBC_NOROUTE		-9 */
	"partially filled",	/* ERR_EBC_NOTCOMPLETE		-10 */
	"already exist",	/* ERR_EBC_EXIST		-11 */
	"connect error",	/* ERR_EBC_CONNECT		-12 */
	"interrupted",		/* ERR_EBC_INTERRUPTED		-13 */
	"wrong packet",		/* ERR_EBC_WRONGPKT		-14 */
	"wrong address",	/* ERR_EBC_ADDRESS		-15 */
	"not exist",		/* ERR_EBC_NOTEXIST		-16 */
};

const char *
ebc_errmsg(ebc_err_t err)
{
	int	idx;

	idx = err * (-1);
	if (idx < 0 || idx >= (sizeof(ebc_strerr) / sizeof(char *)))
		return "";
	return ebc_strerr[idx];
}
